// 
// SoapTrace.Net - A soap message monitoring utility. 
// 
// Copyright (C) 2004 Matthew Ward
// 
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
// 
// Matthew Ward (mrward@users.sourceforge.net)
// 

using NUnit.Framework;
using System;
using WinPcap;
using WinPcap.Tests.Utils;

namespace WinPcap.Tests
{
	/// <summary>
	/// Tests an empty device collection.
	/// </summary>
	[ TestFixture ]
	public class EmptyNetworkInterfaceCollectionTestFixture
	{
		/// <summary>
		/// Empty collection to test.
		/// </summary>
		private NetworkInterfaceCollection m_EmptyCollection;

		/// <summary>
		/// Initialises this test.
		/// </summary>
		[ SetUp ]
		public void Init( )
		{
			m_EmptyCollection = new NetworkInterfaceCollection( );
		}

		/// <summary>
		/// Tests that the collection is empty at start up.
		/// </summary>
		[ Test ]
		public void EmptyAtStart( )
		{
			Assert.AreEqual( 0, m_EmptyCollection.Count, 
				"Collection should be empty when first created." );
		}

		/// <summary>
		/// Tests that we can add an item to the collection.
		/// </summary>
		[ Test ]
		public void AddOneItem( )
		{
			NetworkInterface NetworkInterface = new NetworkInterface( );
			NetworkInterface.Name = "DeviceName";
			m_EmptyCollection.Add( NetworkInterface );

			// Test the addition
			Assert.AreEqual( 1, m_EmptyCollection.Count );
			
			TestUtility.CompareNetworkInterfaces( NetworkInterface, 
				m_EmptyCollection[ 0 ] );

			Assert.AreEqual( 0, NetworkInterface.Addresses.Count, 
				"Should not be any interface addresses" );
//			for( int i = 0; i < NetworkInterface.NetworkInterfaceAddresses.Count; ++i )
//			{
//				TestUtility.CompareNetworkInterfaceAddress( NetworkInterface.NetworkInterfaceAddresses[ i ],
//					m_EmptyCollection[ 0 ].NetworkInterfaceAddresses[ i ] );
//			}
		}
	}
}
